<template>
    <view class="p-l-r">
        <template v-for="row in dataRows" :key="row.id">
            <view class="log-item" @click="nav(row)">
                <view>设备号：{{ row.deviceId }}</view>
                <view class='m-t-10'>状态：{{ WATER_TEST_STATUS[row.status] }}</view>
                <template v-if="row.type == 0">
                    <view>大肠杆菌检测</view>
                </template>
                <template v-else>
                    <view class='m-t-10' v-if="row.status == 4">检测结果：{{ row.result }}</view>
                </template>
                <view class='m-t-10'>开始时间：{{ parseTime(row.createTime) }}</view>
                <view class='m-t-10' v-if="row.status == 4">完成时间：{{ parseTime(row.endTime) }}</view>
            </view>
        </template>
    </view>
    <LoadMore key-name="id" :api="pageApi" @finish="page" />
</template>

<script lang="ts" setup>
    import { pageApi } from '@/api/WaterTest';
    import LoadMore from '@/components/LoadMore/index.vue'
    import { WATER_TEST_STATUS } from '@/constant';
    import { parseTime } from '@/utils';
import { navigateTo } from '@/utils/framework';
    import { ref } from 'vue';
    
    
    const dataRows = ref<any[]>([])

    function page(rows:any[]) {
        dataRows.value.push(...rows)
    }

    function nav(row) {
        if(row.type == 0) {
            navigateTo("./data/index?id=" + row.id)
        }
    }



</script>

<style lang="scss" src="./index.scss"></style>